////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef _CAXISCONTROL_H_
#define _CAXISCONTROL_H_

////////////////////////////////////////////////////////////////////////////////////////////////////

#include "CGlobals.h"
#include "IControl.h"
#include "IrrArray.h"
#include "Vector3d.h"
#include "Vector2d.h"
#include "position2d.h"
#include "SColor.h"

////////////////////////////////////////////////////////////////////////////////////////////////////

// CAxisControl allows the user to move an object by dragging
// the axis drawn on it.
class CAxisControl : public IControl
{
	CAxisControl (); // no default constructor
	CAxisControl (const CAxisControl&); // no copy constructor
	CAxisControl& operator= (const CAxisControl&); // no assignment

public:
	CAxisControl (array<ISceneNode*> nodes, vector3df axis, SColor normalColor, SColor highlightColor);
	virtual ~CAxisControl ();

	virtual bool OnEvent (const SEvent& event);
	virtual void draw ();

private:
	ICameraSceneNode* m_camera;
	array<ISceneNode*> m_nodes;
	vector3df m_axis;
	SColor m_normalColor;
	SColor m_highlightColor;
	bool m_activated;
	bool m_highlighted;
	array<vector3df> m_nodeStartPos;
	array<vector3df> m_nodeStartScale;
	vector3df m_centroid;
	position2di m_mouseStart;

	void getScreenCoordinates (array<vector2df>* coordinates) const;
	bool onMouseEvent (const SEvent::SMouseInput& event);
	bool isPointOverControl (position2di pt) const;
	vector2df getScreenAxis () const;
};

#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
